package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.BmsMpSlideshow;
import com.macro.mall.portal.dto.BmsMpSlideshowParam;
import com.macro.mall.portal.service.BmsMpSlideshowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 轮播图管理Controller
 * Created by macro on 2018/4/26.
 */
@Controller
@Api(tags = "BmsMpSlideshowController")
@Tag(name = "BmsMpSlideshowController", description = "轮播图管理")
@RequestMapping("/mpSlides")
public class BmsMpSlideshowController {
    @Autowired
    private BmsMpSlideshowService bmsMpSlideshowService;


    @ApiOperation("小程序查询轮播图")
    @RequestMapping(value = "/mpList", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsMpSlideshow>> getMpList(@RequestBody BmsMpSlideshowParam bmsMpSlideshowParam) {
        List<BmsMpSlideshow> bmsMpSlideshowList = bmsMpSlideshowService.getMpList(bmsMpSlideshowParam);
        return CommonResult.success(CommonPage.restPage(bmsMpSlideshowList));
    }



    @ApiOperation("小程序查询轮播图详情")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsMpSlideshow> getMpDetail(@PathVariable Long id) {
        BmsMpSlideshow bmsMpSlideshow = bmsMpSlideshowService.getMpDetail(id);
        return CommonResult.success(bmsMpSlideshow);
    }
}
